package com.ruoyi.pos.domain.dto.common.response;

import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 分页查询响应基类
 * 
 * @author ruoyi
 * @date 2025-01-30
 */
@ApiModel(description = "分页查询响应基类")
public class BasePageResponse<T> extends TableDataInfo {

    @ApiModelProperty(value = "总记录数")
    private long total;

    @ApiModelProperty(value = "列表数据")
    private List<T> rows;

    @ApiModelProperty(value = "消息状态码")
    private int code;

    @ApiModelProperty(value = "消息内容")
    private String msg;

    public BasePageResponse() {
        super();
    }

    public BasePageResponse(List<T> list, long total) {
        super(list, total);
        this.rows = list;
        this.total = total;
    }
    
    // 重写父类方法以避免类型擦除冲突
    @Override
    @SuppressWarnings("unchecked")
    public void setRows(List<?> rows) {
        this.rows = (List<T>) rows;
        super.setRows(rows);
    }
    
    @Override
    public List<T> getRows() {
        return this.rows;
    }
    
    @Override
    public long getTotal() {
        return this.total;
    }
    
    @Override
    public void setTotal(long total) {
        this.total = total;
        super.setTotal(total);
    }
    
    @Override
    public int getCode() {
        return this.code;
    }
    
    @Override
    public void setCode(int code) {
        this.code = code;
        super.setCode(code);
    }
    
    @Override
    public String getMsg() {
        return this.msg;
    }
    
    @Override
    public void setMsg(String msg) {
        this.msg = msg;
        super.setMsg(msg);
    }
}
